RTF differences

Hi,

Does anybody know how to show the differences between and old value and a new value which differs by RTF? The old text (with RTF) must be striked and the next text (with RTF) must be underlined

For exemple:

I would like to show the differences between text (bold )and school (italic)like this:
-text- text ( The old value must be striked and bold and the new text must be italic and underlined).

I tried to use the DIFF function but it doesn't work fine for RTF text.

thanks!
Manilla - Tue Sep 15 04:24:07 EDT 2009

Re: RTF differences
Peter_Albert - Tue Sep 15 04:44:33 EDT 2009

I guess you are talking about complete paragraphs to be compared, not just single word values as in your example?

In that case, you should seriously ask yourself whether you really need this functionality. There is no easy way to accomplish this using DXL. You would have to loop through the RichTextParagraphs, and for each RichTextParagraph through each RichText chunk, and you would have to do this in parallel for the old and new values. Quickly, the old and new values decomposition will run out of phase, so you will be comparing apples with pies and get false indications of deletions / modifications / added text in your final result.

And what do you do if one chunk of the old and new value is underlined, but not changed at all? It would appear in your diff string as underlined, falsely indicating that it had been inserted into the text.

The only possible way I could think of would be to use OLE automatisation to write to two temporary Word files, call the Word comparison tool and read the result back from Word. And I doubt that the added value of the result is worth the effort.

Regards,

Peter

Re: RTF differences
llandale - Tue Sep 15 10:22:48 EDT 2009

I agree with Albert; no, just deal with the raw text.

However... If I REALLY had to do this, I'd try this approach: Get the Raw text of both and find the 'diff()' output. IIRC, you can send the 'diff' function hokey highlighting commands such as "\\xxDelete " and "\\xxInsert " and can then expect to find deleted text to be surrounded with "\\xxDelete " and "\\xxDelete0 " tags, and inserted text to be surrounded with "\\xxInsert " and "\\xxInsert0 " tags.

Get the richTextNoOle() of each. Parse the diff output looking for the real chunks of strings. Keep a 3 fingered algorithm noting the current positionsm in the [1] From Raw Text [2] To Raw Text [3] Diff text.

Search the diff output looking for your 4 tags above, finding (raw) text that [1] is unchanged [2] deleted [3] inserted. When it is unchanged use findRichText of the original in both, noting their positions. Put this into the output buffer updating the finger pointers for all 3. When there is an insert, find that raw text in the original RT and put that in the buffer first surrounded with underscore on-off commands; and update the finger pointer for the New and the Output. When there is a deletion likewise find that in the original RT put it in the buffer, likewise first surrounded with strike-out on-off commands; updating the finger position of the Old and the Output.

Good luck understanding that, and better luck putting it into action. I see that the above approach will NOT find the case where you preserved the raw text but just changed its formatting; perhaps bold to bold-italic.

Another approach, perhaps, is to massage the original From and To texts, finding each chunk and its highlighting (for rt in text do...), rebuilding the strings such that diff will recognize it; diff; then parse the output rebuilding RT commands that the processor will understand. Gads.

Nope, don't bother.

  • Louie